﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using MetroWashroom.ViewModels;

namespace MetroWashroom
{
    public partial class LineStation : PhoneApplicationPage
    {
        private bool flag = false;
        public LineStation()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(LineStation_Loaded);
        }

        void LineStation_Loaded(object sender, RoutedEventArgs e)
        {
            if (!flag)//标记用，为了点击back按钮后不用在一次加载数据
                InitStation();
        }

        private void InitStation()
        {
            string stationName = NavigationContext.QueryString["lineName"];//获取地铁的站名
            int num = int.Parse(NavigationContext.QueryString["lineNum"]);//获取地铁属于第几号线
            PivotModel pivotModel = new PivotModel(num, stationName);
            DataContext = pivotModel;
        }

        private void ListBox_Tap(object sender, GestureEventArgs e)
        {
            flag = true;
            ListBox listBox = sender as ListBox;
            Station station = listBox.SelectedItem as Station;
            if (station.ID == -1)
                return;
            //用全局变量来存,当然也可以用url来把值传过去
            App.AppStaton = station;
            NavigationService.Navigate(new Uri("/Washroom.xaml", UriKind.Relative));
        }
    }
}